<template>
    <a-card :body-style="{padding: '24px 32px'}" :bordered="false">
        <a-form>
            <a-form-item
                    :label="$t('expertName')"
                    :labelCol="{span: 7}"
                    :wrapperCol="{span: 10}"
            >
                <a-input :placeholder="$t('expertNameInput')" v-model="items.expertNameInputs"/>
            </a-form-item>

            <a-form-item
                    :label="$t('expertPassword')"
                    :labelCol="{span: 7}"
                    :wrapperCol="{span: 10}"
            >
                <a-input-password placeholder="input password" v-model="items.expertPasswordInputs"/>
                <!--                <a-input :placeholder="$t('expertPasswordInput')" v-model="this.items.expertPasswordInputs"/>-->
            </a-form-item>

            <a-form-item
                    :label="$t('doubleExpertPassword')"
                    :labelCol="{span: 7}"
                    :wrapperCol="{span: 10}"
            >
                <a-input-password placeholder="input password" v-model="items.doubleExpertPasswordInputs"/>
                <!--                <a-input :placeholder="$t('doubleExpertPasswordInput')" v-model="this.items.doubleExpertPasswordInputs"/>-->
            </a-form-item>

            <a-form-item
                    :label="$t('title')"
                    :labelCol="{span: 7}"
                    :wrapperCol="{span: 10}"
            >
                <a-input :placeholder="$t('titleInput')" v-model="items.titleInputs"/>
            </a-form-item>

            <a-form-item
                    :label="$t('technical')"
                    :labelCol="{span: 7}"
                    :wrapperCol="{span: 10}"
            >
                <a-input :placeholder="$t('technicalInput')" v-model="items.technicalInputs"/>
            </a-form-item>

            <a-form-item
                    :label="$t('phone')"
                    :labelCol="{span: 7}"
                    :wrapperCol="{span: 10}"
            >
                <a-input :placeholder="$t('phoneInput')" v-model="items.phoneInputs"/>
            </a-form-item>

            <a-form-item
                    :label="$t('describe')"
                    :labelCol="{span: 7}"
                    :wrapperCol="{span: 10}"
            >
                <a-textarea rows="4" :placeholder="$t('describeInput')" v-model="items.describeInputs"/>
            </a-form-item>

            <a-form-item style="margin-top: 24px" :wrapperCol="{span: 10, offset: 7}">
                <a-button type="primary" @click="ExperSave">{{$t('submit')}}</a-button>
                <a-button @click="test" style="margin-left: 8px">保存</a-button>
            </a-form-item>
        </a-form>
    </a-card>
</template>

<script>
    import Axios from "axios"

    export default {
        name: 'BasicForm',
        i18n: require('./AddingExpertInformation'),
        data() {
            return {
                url: this.$store.state.apiUrl + ':' + this.$store.state.apiPort,
                value: 1,
            }
        },
        computed: {
            desc() {
                return this.$t('pageDesc')
            },
            id() {
                //console.log(this.$route.params.id);
                return this.$route.params.id;
            },
            items() {

                return this.$route.params.item;
            },
        },
        methods: {
            ExperSave() {
               // console.log(this.items.technicalInputs)
                if(this.id==null){
                    Axios.post(this.url + "/pxManagerSystem/addSpecialInfo", {
                        specialist_name: this.items.expertNameInputs,
                        specialist_pass: this.items.expertPasswordInputs,
                        specialist_realname: this.items.titleInputs,
                        professional_title: this.items.technicalInputs,
                        specialist_contact: this.items.phoneInputs
                    })
                        .then(()=>{
                            this.$router.push({name:"专家卡片列表"});
                        })
                }else{
                    Axios.put(this.url + "/pxManagerSystem/updateSpecialBySpecialId", {
                        specialist_id: this.id,
                        specialist_name: this.items.expertNameInputs,
                        specialist_pass: this.items.expertPasswordInputs,
                        specialist_realname: this.items.titleInputs,
                        professional_title: this.items.technicalInputs,
                        specialist_contact: this.items.phoneInputs
                    })
                        .then(()=>{
                            this.$router.push({name:"专家卡片列表"});
                        })
                }
            },
            test() {

            }
        },
    }
</script>

<style scoped>

</style>
